package com.xbts.web.controller.huawei;

import com.huaweicloud.sdk.bss.v2.model.*;
import com.xbts.common.config.XbtsConfig;
import com.xbts.common.core.controller.BaseController;
import com.xbts.common.core.domain.AjaxResult;
import com.xbts.system.domain.dto.HuaweiAccountBindDTO;
import com.xbts.system.domain.dto.RegionIdDTO;
import com.xbts.system.domain.metadata.MetadataBean;
import com.xbts.system.domain.saml.AuthnRequestResolution;
import com.xbts.system.domain.saml.SAMLResponseResolution;
import com.xbts.system.service.IHuaweiAccountService;
import lombok.extern.slf4j.Slf4j;
import org.opensaml.saml2.core.AuthnRequest;
import org.opensaml.saml2.core.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.security.Provider;
import java.security.Security;

@Slf4j
@RestController
@RequestMapping("/huawei")
public class HuaweiAccountController extends BaseController{

//    private static final String SPMETADATAPATH = ServerProperty.getInstance().getProperty("spMetadataPath");

    @Autowired
    private IHuaweiAccountService huaweiAccountService;



    /**
     * 华为云账号绑定通知地
     * @return
     */
    @PostMapping(value = "/account/bind")
    public AjaxResult accountBind(HuaweiAccountBindDTO dto) {
        return huaweiAccountService.accountBind(dto);
    }

    /**
     * https://support.huaweicloud.com/api-bpconsole/mc_00016.html
     * 创建客户
     * @param dto 请求参数
     * @return
     */
    @PostMapping(value = "/createSubCustomer")
    public AjaxResult createSubCustomer(@RequestBody RegionIdDTO<CreateSubCustomerRequest> dto) {
        return huaweiAccountService.createSubCustomer(dto);
    }

    /**
     * https://support.huaweicloud.com/api-bpconsole/mc_00023.html
     * 校验客户注册信息
     * @param dto 请求参数
     * @return
     */
    @PostMapping(value = "/checkUserIdentity")
    public AjaxResult checkUserIdentity(@RequestBody RegionIdDTO<CheckUserIdentityRequest> dto) {
        return huaweiAccountService.checkUserIdentity(dto);
    }

    /**
     * https://support.huaweicloud.com/api-bpconsole/mc_00024.html
     * 发送验证码
     * @param dto 请求参数
     * @return
     */
    @PostMapping(value = "/sendVerificationMessageCode")
    public AjaxResult sendVerificationMessageCode(@RequestBody RegionIdDTO<SendVerificationMessageCodeRequest> dto) {
        return huaweiAccountService.sendVerificationMessageCode(dto);
    }

    /**
     * https://support.huaweicloud.com/api-bpconsole/espp_00003.html
     * 查询云经销商列表
     * @param dto 请求参数
     * @return
     */
    @PostMapping(value = "/listIndirectPartners")
    public AjaxResult listIndirectPartners(@RequestBody RegionIdDTO<ListIndirectPartnersRequest> dto) {
        return huaweiAccountService.listIndirectPartners(dto);
    }

    /**
     * https://support.huaweicloud.com/api-bpconsole/mc_00021.html
     * 查询客户列表
     * @param dto 请求参数
     * @return
     */
    @PostMapping(value = "/listSubCustomers")
    public AjaxResult listSubCustomers(@RequestBody RegionIdDTO<ListSubCustomersRequest> dto) {
        return huaweiAccountService.listSubCustomers(dto);
    }


    /**
     * 获取华为云登录链接参数
     */
    @GetMapping(value = "/loginParameters")
    public AjaxResult loginParameters() {
        return huaweiAccountService.loginParameters();
    }


}
